/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package kimo.persistence.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author a381u296
 */
@Entity
@Table(name = "raw_product_type")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "RawProductType.findAll", query = "SELECT r FROM RawProductType r"),
    @NamedQuery(name = "RawProductType.findByRawProductTypeId", query = "SELECT r FROM RawProductType r WHERE r.rawProductTypeId = :rawProductTypeId"),
    @NamedQuery(name = "RawProductType.findByRawProductTypeName", query = "SELECT r FROM RawProductType r WHERE r.rawProductTypeName = :rawProductTypeName")})
public class RawProductType implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "raw_product_type_id")
    private Integer rawProductTypeId;
    @Basic(optional = false)
    @Column(name = "raw_product_type_name")
    private String rawProductTypeName;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "rawProductTypeId")
    private List<RawProduct> rawProductList;

    public RawProductType() {
    }

    public RawProductType(Integer rawProductTypeId) {
        this.rawProductTypeId = rawProductTypeId;
    }

    public RawProductType(Integer rawProductTypeId, String rawProductTypeName) {
        this.rawProductTypeId = rawProductTypeId;
        this.rawProductTypeName = rawProductTypeName;
    }

    public Integer getRawProductTypeId() {
        return rawProductTypeId;
    }

    public void setRawProductTypeId(Integer rawProductTypeId) {
        this.rawProductTypeId = rawProductTypeId;
    }

    public String getRawProductTypeName() {
        return rawProductTypeName;
    }

    public void setRawProductTypeName(String rawProductTypeName) {
        this.rawProductTypeName = rawProductTypeName;
    }

    @XmlTransient
    public List<RawProduct> getRawProductList() {
        return rawProductList;
    }

    public void setRawProductList(List<RawProduct> rawProductList) {
        this.rawProductList = rawProductList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (rawProductTypeId != null ? rawProductTypeId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RawProductType)) {
            return false;
        }
        RawProductType other = (RawProductType) object;
        if ((this.rawProductTypeId == null && other.rawProductTypeId != null) || (this.rawProductTypeId != null && !this.rawProductTypeId.equals(other.rawProductTypeId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return rawProductTypeName;
    }
    
}
